package com.clive.llweb.controller;

import com.clive.llweb.bean.DishesCategory;
import com.clive.llweb.service.DishCategoryService;
import com.clive.llweb.vo.DishResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/dishesCategory")
@CrossOrigin
public class DishCategoryController {
    @Autowired
    private DishCategoryService dishCategoryService;
    @RequestMapping("/all")
    public DishResult findDishCategoryAll(){
//        controller调用service
        List<DishesCategory> list = dishCategoryService.findDishesCategoryAll();
        System.out.println(list);
        return DishResult.ok().date("categoryList",list);
    }
    @RequestMapping("/delete/{id}")
    public DishResult deleteDishCategory(@PathVariable Integer id){
        int count = dishCategoryService.deleteDishCategory(id);
//        返回删除的是哪个菜品分类的执行条数
        return DishResult.ok().date("count",count);
    }
}
